home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: lugb.latrobe.edu.au!latcs1!woelkerl
- From: woelkerl@lion.cs.latrobe.edu.au (Eric Woelkerling)
- Subject: Pointer to Functions and Calls thereof??
- X-Nntp-Posting-Host: lion.cs.latrobe.edu.au
- Message-ID: <Dq017E.DL6@latcs1.lat.oz.au>
- Sender: news@latcs1.lat.oz.au (news)
- Organization: Comp.Sci & Comp.Eng, La Trobe Uni, Australia
- X-Newsreader: TIN [version 1.2 PL2]
- Date: Wed, 17 Apr 1996 09:04:26 GMT
-
-
- I'm having some trouble getting a pointer to a function to work
- (ie. I want to be able to point to a function and call the function with
- this pointer ). I have a situation where a number of routines are needed,
- but only one will be selected for use through the entire program, however
- this will change each run-time. Is there an easy way to get a pointer to this
- function and call...
-
-
- So far - I've only got as far as..
-
- void func1(void){various bits}
- void func2(void){various bits}
-
- void main()
- { void *a[1];
-
- a[0]=func1;
- a[1]=func2;
-
- (*a[0])();
- (*a[1])();
- }
-
-
-
- What is the obvious thing I am missing here?? This is on a PC
- using Borland C++. It tells me that (*a[1])() is "not an allowed type".
-
- Any Ideas?
-
- Please email me directly.. Thanks!
- Eric Woelkerling..
- woelkerl@lion.lat.oz.au
-
-
-